package com.jiangruan.javaproject.request.service;

import com.alibaba.fastjson.JSONObject;
import com.jiangruan.javaproject.Constants;
import com.jiangruan.javaproject.entity.HotVideoCommon;
import com.jiangruan.javaproject.entity.NewsHead;
import com.jiangruan.javaproject.entity.NewsHeadCommon;
import com.jiangruan.javaproject.request.HttpUtils;

import java.util.List;

/**
 * @author:liufukai
 * @email:1324963242@qq.com
 * @desc:
 * @datatime:2021/12/2817:21
 */
public class NewsHeadService {

    public List<NewsHead> getNewsHead(){
    String url= Constants.News_URL+"?key="+Constants.News_KEY+"&type=top"+"&page_size=20"+"&is_filter=1";
    String result = HttpUtils.get(url);
        System.out.println(result);
    //json解析
        NewsHeadCommon newsHeadCommon = JSONObject.parseObject(result, NewsHeadCommon.class);
        System.out.println(newsHeadCommon.result.size());

        return newsHeadCommon.result;
    }
}
